package com.own.business.log.operation.persistence.entity.map;

import com.own.business.log.operation.persistence.entity.po.LogOperation;
import com.own.component.common.base.entity.BaseMap;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * LogOperationMapVo
 *
 * @author chenxueli
 * @date 2023-08-09 10:24:19
 */
@Schema(title = "操作日志持久化" + ConstantBeanSuffix.MAP_VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class LogOperationMapVo extends BaseMap<LogOperation> implements Serializable {

    @Schema(title = "操作编码")
    private String code;

    @Schema(title = "响应信息")
    private String message;

    @Schema(title = "登录令牌")
    private String token;

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "用户名")
    private String userName;

    @Schema(title = "状态 1=成功 2=失败")
    private Integer status;

    @Schema(title = "方法名（全限定名）")
    private String methodName;

    @Schema(title = "客户端")
    private String client;

    @Schema(title = "ip")
    private String ip;

    @Schema(title = "模块名称")
    private String moduleName;

    @Schema(title = "操作名称")
    private String operationName;

    @Schema(title = "请求时间")
    private LocalDateTime requestTime;

    @Schema(title = "请求参数")
    private String requestParams;

    @Schema(title = "响应时间")
    private LocalDateTime responseTime;

    @Schema(title = "响应参数")
    private String responseParams;

    @Schema(title = "链路id")
    private String traceId;

    @Schema(title = "等级")
    private Integer level;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public LogOperationMapVo(@NonNull LogOperation entity) {
        super(entity);
        this.code = entity.getCode();
        this.message = entity.getMessage();
        this.token = entity.getToken();
        this.userId = entity.getFkUserId();
        this.userName = entity.getUserName();
        this.status = entity.getStatus();
        this.methodName = entity.getMethodName();
        this.client = entity.getClient();
        this.ip = entity.getIp();
        this.moduleName = entity.getModuleName();
        this.operationName = entity.getOperationName();
        this.requestTime = entity.getRequestTime();
        this.requestParams = entity.getRequestParams();
        this.responseTime = entity.getResponseTime();
        this.responseParams = entity.getResponseParams();
        this.traceId = entity.getTraceId();
        this.level = entity.getLevel();
    }

}
